/*
 * Copyright 2003-2006 (c) Live Media Pty Ltd. <argot@einet.com.au> 
 *
 * This software is licensed under the Argot Public License 
 * which may be found in the file LICENSE distributed 
 * with this software.
 *
 * More information about this license can be found at
 * http://www.einet.com.au/License
 * 
 * The Developer of this software is Live Media Pty Ltd,
 * PO Box 4591, Melbourne 3001, Australia.  The license is subject 
 * to the law of Victoria, Australia, and subject to exclusive 
 * jurisdiction of the Victorian courts.
 */

%module(package = "argot") type
%{
	#include "Types.h"
	#include "TypeBindCommon.h"
	#include "common/BigEndianUnsignedShort.h"
%}

%include exception.i
%include "argot_exception.i"
%include "utils.i"

// ------------------------------------------------------------------------------------------------

%fix_naming_to( type_name, TypeName );
%fix_naming_to( type_buffer, TypeBuffer );
%fix_naming_to( argot_error, ArgotError );
%fix_naming_to( type_writer, TypeWriter );
%fix_naming_to( type_reader, TypeReader );

%include "TypePlatform.h"

%inline
%{
	#include <string.h>
	
	void type_name_ctor( type_name* e, const char* name )
	{
		e->name = strdup(name);
	}
%}

%include "Types.h"

%set_constructor_1( type_name, type_name_ctor, const char*, name );

// ------------------------------------------------------------------------------------------------
%fix_naming_to( type_object, TypeObject );

%exception type_object_bind
{
	ArgotConditionalExc(result != TYPE_OK, SWIG_ValueError, "error binding object, check library error code if you need more info" );
}

%include "TypeObject.h"

%add_bound_method( type_object, int, bind, type_object_bind, type_library * library, type_name * name )
%add_readonly_prop( type_object, type_element*, element, type_object_element )
%add_readonly_prop( type_object, type_name*, name, type_object_name )
%add_readonly_prop( type_object, type_library*, library, type_object_library )
%add_readonly_prop( type_object, int, id, type_object_id )


// ------------------------------------------------------------------------------------------------
%include "type_element.i"
// ------------------------------------------------------------------------------------------------
%fix_naming_to( type_definition, TypeDefinition );
%include "TypeDefinition.h"
// ------------------------------------------------------------------------------------------------
%include "type_library.i"
// ------------------------------------------------------------------------------------------------
%include "type_map.i"
// ------------------------------------------------------------------------------------------------
%include "type_stack.i"
// ------------------------------------------------------------------------------------------------
%include "type_streams.i"
// ------------------------------------------------------------------------------------------------
%exception type_reader_auto
{
	ArgotConditionalExc( result == TYPE_EOF, SWIG_ValueError, "EOF occured in TypeReaderAuto" )
}
%include "TypeReaderAuto.h"

%type_reader_auto_callback_code

// ------------------------------------------------------------------------------------------------
%exception type_core_init
{
	ArgotConditionalExc (result != TYPE_OK, SWIG_ValueError, "error initing core" )
}
%include "TypeCore.h"
// ------------------------------------------------------------------------------------------------
%include "TypeMapCore.h"

%inline
{
	void py_type_map_core_get_identifiers( type_map* map, int** ids, int* size )
	{
		type_map_core_get_identifiers( map, ids, size );
	}
}

%inline
{
	type_element* cast_to_type_element(void* element)
	{
		return (type_element*)element;
	}
}
// ------------------------------------------------------------------------------------------------

%fix_naming_to( type_bind_common, bind_common );
%include "TypeBindCommon.h"

// ------------------------------------------------------------------------------------------------
